<template>
  <div id="app">

    
    
    <router-view />
    <musicPlayerBar/>
    <!-- <play-list /> -->
    <van-tabbar v-model="active" route fixed  placeholder>
        <van-tabbar-item replace to="/" icon="home-o">推荐</van-tabbar-item>
        <van-tabbar-item replace to="/about" icon="hot-o">排行</van-tabbar-item>
    </van-tabbar>

    <PageTaraget v-if="openPage!=''" :targetName='openPage' @hook:destroyed="openPage=''" :propData="targetData" style="margin-left:-5vw"/>
  </div>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>

<script>
import musicPlayerBar from '@/components/wl/musicPlayerBar.vue'
import PageTaraget from "@/components/wl/pageTaraget.vue";

export default{
  components:{
    musicPlayerBar,
    PageTaraget
  },
  data(){
    return {
      active:0,

      // 弹出层信息
      
      openPage:"",
      targetData:{},
    }
  },
  mounted() {
    window.addEventListener('unload',this.saveState);
    this.$EventBus.$on('openTargetWindow', (res) => {
      this.targetData = res["data"]||res["d"] ;
      this.openPage=res["openPage"]||res["o"];
			//	handle event data
		});
  },
  beforeDestroyed() {
		this.$EventBus.$off('openTargetWindow');
	},
  methods:{
    saveState(){
      // console.log("保存数据",JSON.stringify(this.$store.state))
      sessionStorage.setItem('store.state',JSON.stringify(this.$store.state))
    }
  }
}
</script>

